home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / netinet / if_ether.h < prev    next >
Text File  |  1995-02-14  |  6KB  |  168 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * Copyright (c) 1982, 1986 Regents of the University of California.
  9.  * All rights reserved.
  10.  *
  11.  * Redistribution and use in source and binary forms are permitted
  12.  * provided that the above copyright notice and this paragraph are
  13.  * duplicated in all such forms and that any documentation,
  14.  * advertising materials, and other materials related to such
  15.  * distribution and use acknowledge that the software was developed
  16.  * by the University of California, Berkeley.  The name of the
  17.  * University may not be used to endorse or promote products derived
  18.  * from this software without specific prior written permission.
  19.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  21.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  22.  *
  23.  *    @(#)if_ether.h    7.3 (Berkeley) 6/29/88 plus MULTICAST 1.0
  24.  *
  25.  * HISTORY
  26.  * 11-Jul-93  Mac Gillon (mgillon) at NeXT
  27.  *    Integrated MULTICAST support
  28.  *
  29.  * 09-Apr-90  Bradley Taylor (btaylor) at NeXT, Inc.
  30.  *    Move Ethernet definitions to <net/etherdefs.h>. Leave arp stuff here.
  31.  *
  32.  * 20-Oct-87  Peter King (king) at NeXT, Inc.
  33.  *    SUN_RPC: Add definition for ether_addr.  Add RARP support.
  34.  *
  35.  * 25-Jan-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  36.  *    Upgraded to 4.3.
  37.  *
  38.  * 15-Aug-85  Mike Accetta (mja) at Carnegie-Mellon University
  39.  *    CS_INET:  added ac_if field to arptab definition to allow
  40.  *    multiple interfaces to co-exist.
  41.  *    [V1(1)]
  42.  */
  43.  
  44. /*    @(#)if_ether.h    2.1 88/05/18 4.0NFSSRC SMI;    from UCB 7.1 6/5/86    */
  45.  
  46. #import <net/etherdefs.h>
  47.  
  48.  
  49. /*
  50.  * Ethernet Address Resolution Protocol.
  51.  *
  52.  * See RFC 826 for protocol description.  Structure below is adapted
  53.  * to resolving internet addresses.  Field names used correspond to 
  54.  * RFC 826.
  55.  */
  56. struct    ether_arp {
  57.     struct    arphdr ea_hdr;    /* fixed-size header */
  58.     u_char    arp_sha[6];    /* sender hardware address */
  59.     u_char    arp_spa[4];    /* sender protocol address */
  60.     u_char    arp_tha[6];    /* target hardware address */
  61.     u_char    arp_tpa[4];    /* target protocol address */
  62. };
  63. #define    arp_hrd    ea_hdr.ar_hrd
  64. #define    arp_pro    ea_hdr.ar_pro
  65. #define    arp_hln    ea_hdr.ar_hln
  66. #define    arp_pln    ea_hdr.ar_pln
  67. #define    arp_op    ea_hdr.ar_op
  68.  
  69.  
  70. /*
  71.  * Structure shared between the ethernet driver modules and
  72.  * the address resolution code.  For example, each ec_softc or il_softc
  73.  * begins with this structure.
  74.  */
  75. struct arpcom {
  76.     struct ifnet ac_if;                    /* network-visible interface */
  77.     u_char ac_enaddr[6];                /* ethernet hardware address */
  78.     struct in_addr ac_ipaddr;            /* copy of ip address- XXX */
  79.     struct ether_multi *ac_multiaddrs;    /* list of ether multicast addrs */
  80. };
  81.  
  82. /*
  83.  * Internet to ethernet address resolution table.
  84.  */
  85. struct arptab {
  86.     struct in_addr at_iaddr;            /* internet address */
  87.     u_char at_enaddr[6];                /* ethernet address */
  88.     u_char at_timer;                    /* minutes since last reference */
  89.     u_char at_flags;                    /* flags */
  90.     struct mbuf *at_hold;                /* one element packet buffering */
  91.     struct ifnet *at_if;                /* interface (CS_INET) */
  92. };
  93.  
  94. #ifdef    KERNEL
  95. u_char etherbroadcastaddr[6];
  96. struct    arptab *arptnew();
  97. char *ether_sprintf();
  98. #endif
  99.  
  100. /*
  101.  * Ethernet multicast address structure.  There is one of these for each
  102.  * multicast address or range of multicast addresses that we are supposed
  103.  * to listen to on a particular interface.  They are kept in a linked list,
  104.  * rooted in the interface's arpcom structure.  (This really has nothing to
  105.  * do with ARP, or with the Internet address family, but this appears to be
  106.  * the minimally-disrupting place to put it.)
  107.  */
  108. struct ether_multi {
  109.     u_char enm_addrlo[6];            /* low  or only address of range */
  110.     u_char enm_addrhi[6];            /* high or only address of range */
  111.     struct arpcom *enm_ac;            /* back pointer to arpcom        */
  112.     u_int enm_refcount;                /* no. claims to this addr/range */
  113.     struct ether_multi *enm_next;    /* ptr to next ether_multi       */
  114. };
  115.  
  116. #ifdef KERNEL
  117. /*
  118.  * Structure used by macros below to remember position when stepping through
  119.  * all of the ether_multi records.
  120.  */
  121. struct ether_multistep {
  122.     struct ether_multi  *e_enm;
  123. };
  124.  
  125. /*
  126.  * Macro for looking up the ether_multi record for a given range of Ethernet
  127.  * multicast addresses connected to a given arpcom structure.  If no matching
  128.  * record is found, "enm" returns NULL.
  129.  */
  130. #define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm)            \
  131.     /* u_char              addrlo[6]; */                \
  132.     /* u_char              addrhi[6]; */                \
  133.     /* struct arpcom      *ac;        */                \
  134.     /* struct ether_multi *enm;       */                \
  135. {                                    \
  136.     for ((enm) = (ac)->ac_multiaddrs;                \
  137.          (enm) != NULL &&                        \
  138.         (bcmp((enm)->enm_addrlo, (addrlo), 6) != 0 ||        \
  139.          bcmp((enm)->enm_addrhi, (addrhi), 6) != 0);        \
  140.          (enm) = (enm)->enm_next);                    \
  141. }
  142.  
  143. /*
  144.  * Macro to step through all of the ether_multi records, one at a time.
  145.  * The current position is remembered in "step", which the caller must
  146.  * provide.  ETHER_FIRST_MULTI(), below, must be called to initialize "step"
  147.  * and get the first record.  Both macros return a NULL "enm" when there
  148.  * are no remaining records.
  149.  */
  150. #define ETHER_NEXT_MULTI(step, enm)                    \
  151.     /* struct ether_multistep  step; */                \
  152.     /* struct ether_multi     *enm;  */                \
  153. {                                    \
  154.     if (((enm) = (step).e_enm) != NULL)                \
  155.         (step).e_enm = (enm)->enm_next;                \
  156. }
  157.  
  158. #define ETHER_FIRST_MULTI(step, ac, enm)                \
  159.     /* struct ether_multistep  step; */                \
  160.     /* struct arpcom          *ac;   */                \
  161.     /* struct ether_multi     *enm;  */                \
  162. {                                    \
  163.     (step).e_enm = (ac)->ac_multiaddrs;                \
  164.     ETHER_NEXT_MULTI((step), (enm));                \
  165. }
  166. #endif KERNEL
  167.  
  168.